/**
 * 文件名称 : AndroidAudio.java
 * <p>
 * 作者信息 : maidou
 * <p>
 * 创建时间 : 2011-8-3, 上午5:57:23
 * <p>
 * 版权声明 : Copyright (c) 2009-2012 CIeNET Ltd. All rights reserved
 * <p>
 * 评审记录 :
 * <p>
 */

package com.ttomato.game.framework.impl;

import java.io.IOException;

import android.app.Activity;
import android.content.res.AssetFileDescriptor;
import android.content.res.AssetManager;
import android.media.AudioManager;
import android.media.SoundPool;

import com.ttomato.game.framework.Audio;
import com.ttomato.game.framework.Music;
import com.ttomato.game.framework.Sound;

/**
 * 请在这里增加文件描述
 * <p>
 */
public class AndroidAudio implements Audio
{
    AssetManager mAssets;
    
    SoundPool mSoundPool;
    
    public AndroidAudio(Activity activity)
    {
        activity.setVolumeControlStream(AudioManager.STREAM_MUSIC);
        
        mAssets = activity.getAssets();
        
        mSoundPool = new SoundPool(20, AudioManager.STREAM_MUSIC, 0);
    }
    
    
    public Music newMusic(String fileName)
    {
        // TODO Auto-generated method stub
        try
        {
            AssetFileDescriptor assetFileDescriptor = mAssets.openFd(fileName);
            return null;
        }
        catch (IOException e)
        {
            // TODO Auto-generated catch block
            throw new RuntimeException("Couldn't load music '" + fileName + "'");
        }
    }
    
    
    public Sound newSound(String fileName)
    {
        // TODO Auto-generated method stub
        try
        {
            AssetFileDescriptor assetFileDescriptor = mAssets.openFd(fileName);
            int soundId = mSoundPool.load(assetFileDescriptor, 0);
            return null;
        }
        catch (IOException e)
        {
            // TODO Auto-generated catch block
            throw new RuntimeException("Couldn't load sound '" + fileName + "'");
        }
        
    }
    
}
